#!/usr/bin/perl -w
#===============================================================================
#
#         FILE:  File_Generation_Time_Check.pl 
#
#        USAGE:  File_Generation_Time_Check.pl
#
#  DESCRIPTION:  
#
#      OPTIONS:  ---
# REQUIREMENTS:  ---
#         BUGS:  ---
#        NOTES:  ---
#       AUTHOR:  ZHOU LEI , <networklei@gmail.com>
#      COMPANY:  ultrapower
#      VERSION:  1.0
#      CREATED:  09/15/2009 22:35:17 PM CST
#     REVISION:  ---
#===============================================================================
use Time::Local;

$DIR = "/home/lester/Perl/Test";

chdir $DIR;

@list=`ls -lrt  | grep CF`;

$_=pop(@list);

@file_name = split(" ",$_);

$file_name = pop(@file_name);

$file_time = (stat $file_name)[9];

print "File  Time : $file_time\n";

chomp($_ = `date '+%Y%m%d%H%M%S'`);

/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ or die "Not a date";

$local_time = timelocal($6,$5,$4,$3,$2 - 1,$1);

print "Local Time : $local_time\n";

$time_difference = $local_time - $file_time;

print "Time Difference : $time_difference\n";

if ($time_difference < 300){
        print "File Generation Check ok\n"
}
else{
        print "File Generation timeOut\n"
}

